 Ext.namespace("Ext.ux.login");
 
 Ext.ux.login.ModifyPwdPanel = Ext.extend(Ext.Panel, {
 	layout: 'fit',
 	formPanel:null,
 	parentWinId: null,
 	
 	initComponent: function(){
 		
 		Ext.ux.login.ModifyPwdPanel.superclass.initComponent.call(this);
	    var fileInputPanel = new Ext.form.FormPanel({
    		labelAlign: 'right',
       		frame: true,
       		//reader: nu,
        	bodyStyle: 'padding:5px 5px 0',
       		width: 300,
       		items: [{
       		 	layout: 'form',
       		 	xtype: 'fieldset',
		        title: '<span class="fs_tip">请输入新密码，标志 <span class="fs_flag">*</span> 字段为必填项</span>',
	       		items:[{
	       			layout: 'column',
		       		items:[{
		       			columnWidth: 1,
		       			layout: 'form',
		       			items: [{
			       			fieldLabel: '<span class="fs_flag">*</span>&nbsp;旧密码',
			       			name: 'old_password',
			       			xtype: 'textfield',
			       			inputType: 'password',
			       			allowBlank: false,
							maxLength: 25,
			       			anchor: '90%'
		       		 	}]
		       		}]},{
		       		 	layout: 'column',
		       		 	items:[
		 					{
			       		 		columnWidth: 1,
			       		 		layout: 'form',
			       		 		items: [{
			       		 			xtype : 'textfield',
									name : 'new_password',
									inputType: 'password',
			       					allowBlank: false,
									fieldLabel : '<span class="fs_flag">*</span>&nbsp;新密码',
									anchor : "90%"
			       		 		}]
		       		 		}]
	       		 	},{
	       		 	layout: 'column',
		       		 	items:[{
		       		 		columnWidth: 1,
		       		 		layout: 'form',
		       		 		items: [{
		       		 			xtype: 'textfield',
								name:'new_password_',
								inputType: 'password',
			       				allowBlank: false,
		       		 			fieldLabel: '<span class="fs_flag">*</span>确认新密码',
			       		 		anchor: '90%'
		       		 		}]
		       		 	}]
	       		 	}]
       		 }],
       		 buttons: [{
				text: '&nbsp;&nbsp;保存',
				width: 90,
				iconCls: 'icon-middle-save',
				scale: 'medium',
				handler: this.saveItem,
				scope: this
			}]
    	});
		fileInputPanel.addButton({
				text: '关闭窗口',
				width: 90,
				iconCls: 'icon-middle-cancel',
				scale: 'medium',
				handler: function(button, e){
					this.closeParentWin();
				},
				scope: this
			})
 		this.add(fileInputPanel);
 		this.formPanel = fileInputPanel;
 	},
 	
 	closeParentWin: function(){
 		var parentWin = Ext.getCmp(this.parentWinId);
 		parentWin.close();
 	},
 	
 	saveItem: function(){
 		if(this.formPanel.form.isValid()){
 			if(this.formPanel.form.findField('new_password').getValue()!=this.formPanel.form.findField('new_password_').getValue()){
 				 Ext.Msg.alert('系统提示', '输入的新密码不一致');
 			}else{
 			this.formPanel.form.submit({
 				url: ctx+'/ps-index!modifyPwd.action',
 				success: function(form, action) {
 					if(action.result.message){
 				    Ext.Msg.alert('系统提示', '密码修改成功！');
 					if(this.parentWinId == null){
 					}
 					else{
 						var itemQueryPanel = Ext.getCmp('itemQueryPanel');
 						if(itemQueryPanel){
 							itemQueryPanel.clearSearchForm();
 						}
						this.closeParentWin();
 					}}else{
 						 Ext.Msg.alert('系统提示', '修改失败！输入的旧密码不正确');
 					}
					
				},
				failure: function(form, action) {
					Ext.Msg.alert('系统提示', '修改密码失败！');
				},
				waitMsg: '正在保存数据，请稍候...',
				scope:this
 			});
 			}
 		}
 	}
 	
 });